package com.jiayang.hhotel.presenter;

import com.jiayang.hhotel.bean.BuildNoModel;
import com.jiayang.hhotel.net.Api;
import com.jiayang.hhotel.ui.BuildingNoActivity;

import cn.droidlover.xdroidmvp.mvp.XPresent;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.NetError;
import cn.droidlover.xdroidmvp.net.XApi;

/**
 * Created by Administrator on 2017/5/4 0004.
 */

public class PBuildNo  extends XPresent<BuildingNoActivity>{
    protected static final int PAGE_SIZE = 10;


    public void loadData( final int page,Long mpAcct,String mpOperation,String mpTablename,String mpCode,int mpGetcode) {
        Api.getBuildNoService().getBuildNoList(page,PAGE_SIZE,mpAcct,mpOperation,mpTablename,mpCode,mpGetcode)
                .compose(XApi.<BuildNoModel>getApiTransformer())
                .compose(XApi.<BuildNoModel>getScheduler())
                .compose(getV().<BuildNoModel>bindToLifecycle())
                .subscribe(new ApiSubscriber<BuildNoModel>() {
                    @Override
                    protected void onFail(NetError error) {
                        getV().showError(error);
                    }

                    @Override
                    public void onNext(BuildNoModel Results) {
                        getV().setData(page,Results);
                    }
                });
    }
}

